﻿//-----------------------------------------------------------------------------
//

//
//
//-----------------------------------------------------------------------------
// Exo² samples - networkest
// Copyright (C) 2007-2009 Samuel Lacroix and Raphaël Legouge
//
// Distributed under GNU General Public License
// See the License folder of Exo² for details
//
//
// http://www.codeplex.com/exo2 (eng)
//-----------------------------------------------------------------------------


#ifndef TEST_H
#define TEST_H
#pragma once


#include "server.h"
#include "client.h"
#include "network/network.h"


#define NO_POSTIT


class CTest : public Exo2::CApplication
{
    public:
    // Construction / destruction    
        CTest();
        ~CTest() {}
        
        static CTest* GetTest();
        
                
    private:
    // Network
        scoped_ptr<Exo2::CNetService> pNetworkService;
        // Server
        scoped_ptr<CNetServer> pServer;
        bool CreateServerCmd(const std::vector<tstring>& Instructions);
        bool DestroyServerCmd(const std::vector<tstring>& Instructions);
        bool ServerKickCmd(const std::vector<tstring>& Instructions);
        bool ServerBanCmd(const std::vector<tstring>& Instructions);
        bool ServerUnbanCmd(const std::vector<tstring>& Instructions);
        bool ServerBannedCmd(const std::vector<tstring>& Instructions);
        bool ServerPeersInfoCmd(const std::vector<tstring>& Instructions);
        bool ServerWelcomMessageCmd(const std::vector<tstring>& Instructions);
        bool ServerPlayersInfoCmd(const std::vector<tstring>& Instructions);
        bool ServerSayCmd(const std::vector<tstring>& Instructions);
        bool ServerUnlagCmd(const std::vector<tstring>& Instructions);
        bool ServerMaxUnlagCmd(const std::vector<tstring>& Instructions);
        
        // Client 0
        scoped_ptr<CNetClient> pClient0;
        bool Join0Cmd(const std::vector<tstring>& Instructions);
        bool Quit0Cmd(const std::vector<tstring>& Instructions);
        bool Name0Cmd(const std::vector<tstring>& Instructions);
        bool UpRate0Cmd(const std::vector<tstring>& Instructions);
        bool CmdRate0Cmd(const std::vector<tstring>& Instructions);
        bool Interp0Cmd(const std::vector<tstring>& Instructions);
        bool Predict0Cmd(const std::vector<tstring>& Instructions);
        bool Extrapol0Cmd(const std::vector<tstring>& Instructions);
        bool Say0Cmd(const std::vector<tstring>& Instructions);

        // Client 1
        scoped_ptr<CNetClient> pClient1;
        bool Join1Cmd(const std::vector<tstring>& Instructions);
        bool Quit1Cmd(const std::vector<tstring>& Instructions);
        bool Name1Cmd(const std::vector<tstring>& Instructions);
        bool UpRate1Cmd(const std::vector<tstring>& Instructions);
        bool CmdRate1Cmd(const std::vector<tstring>& Instructions);
        bool Interp1Cmd(const std::vector<tstring>& Instructions);
        bool Predict1Cmd(const std::vector<tstring>& Instructions);
        bool Extrapol1Cmd(const std::vector<tstring>& Instructions);
        bool Say1Cmd(const std::vector<tstring>& Instructions);
        
    // Application
        bool ControlClient0;
        bool RenderClient0;
        bool NetGraph;
        shared_ptr<Exo2::CSpriteText> pNetgraphText;
        std::vector<tstring> NetgraphTitles;
        tstring GetNetgraphString(const scoped_ptr<CNetClient>& pClient);
        bool SwitchControlCmd(const std::vector<tstring>& Instructions);
        bool SwitchRenderCmd(const std::vector<tstring>& Instructions);
        bool NetgraphCmd(const std::vector<tstring>& Instructions);
        
    // Misc
        static CTest* pTest;
        
        IDirect3DDevice9* pDev;
        void RegisterConfigProperties();
        void RegisterGameActions();
        void DeviceCreated();
        void DeviceDestroyed();
        void DeviceReset(); 
        void DeviceLost();
        void OnCreated();
        void OnDestroying();
        void Update(double TotalTime, float ElapsedTime);
        void Render3D() const;
        void Render2D() const;
        LPCTSTR GetAppGUID() const { return _T("{480761E3-6A58-4cc4-A63B-BCD850B5F922}"); }             // Génèré le dimanche 15 février 2009 17:46:18
};


class CChooseControlCommand : public Exo2::CShellCommand
{
    public:
        CChooseControlCommand(const tstring& Name, const tstring& Usage, const tstring& Description, Exo2::CShellCommand::TCallback Callback, Exo2::CShell::TScopeLevel Scope);
        ~CChooseControlCommand() {}

    private:
        // Copie interdite
        CChooseControlCommand(const CChooseControlCommand& );
        CChooseControlCommand& operator=(const CChooseControlCommand& );
};


class CChooseRenderCommand : public Exo2::CShellCommand
{
    public:
        CChooseRenderCommand(const tstring& Name, const tstring& Usage, const tstring& Description, Exo2::CShellCommand::TCallback Callback, Exo2::CShell::TScopeLevel Scope);
        ~CChooseRenderCommand() {}

    private:
        // Copie interdite
        CChooseRenderCommand(const CChooseRenderCommand& );
        CChooseRenderCommand& operator=(const CChooseRenderCommand& );
};
 

#endif